### Re-examining Civil War: Ethnicity, Horizontal Inequality, and Space
### Grant Gordon & Evann Smith

load("imp1M.RData")
load("imp2M.RData")
load("imp3M.RData")
load("imp4M.RData")
load("imp5M.RData")

model.list <- list(length=4)

for (i in 1:4) {
	imp1 <- imp1.models[[i]]
	imp2 <- imp2.models[[i]]
	imp3 <- imp3.models[[i]]
	imp4 <- imp4.models[[i]]
	imp5 <- imp5.models[[i]]
	n <- length(imp1.models[[i]][,1])
	mat <- matrix(data=NA, ncol=4, nrow=n)
	colnames(mat) <- c("Estimate", "SE", "t-Score", "Significance")
	impnames <- rownames(imp1)
	rnames <- c(impnames[1:(n-5)], "time1", "time2", "time3", "time4", "W")
	rownames(mat) <- rnames
	mat <- data.frame(mat)
	for (j in 1:n) {
		ests <- c(imp1[j,1], imp2[j,1], imp3[j,1], imp4[j,1], imp5[j,1])
		mests <- mean(ests, na.rm=TRUE)
		mat[j,1] <- mests
		ses <- c(imp1[j,2], imp2[j,2], imp3[j,2], imp4[j,2], imp5[j,2])
		mses <- sqrt(mean(ses^2, na.rm=TRUE) + var(ests, na.rm=TRUE)*(1 + (1/5)))
		mat[j,2] <- mses
		tscore <- mests/mses
		mat[j,3] <- tscore
		if (abs(tscore) >= 2.576) {
			mat[j,4] <- "***"
			} else {
				if (abs(tscore) >= 1.96) {
					mat[j,4] <- "**"
					} else {
						if (abs(tscore) >= 1.645) {
							mat[j,4] <- "*"
							} else {
								mat[j,4] <- " "
								}
						}
				}
		}
	model.list[[i]] <- mat
	}

model.list
